package com.example.tome.module_mvp_home;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.example.tome.component_router.arouter.RouterCenter;
import com.example.tome.component_router.arouter.RouterURLS;
import com.example.tome.component_router.retrofit.DataManager;
import com.example.tome.component_router.retrofit.bean.LoginBean;
import com.example.tome.component_router.retrofit.bean.LoginResponse;
import com.example.tome.module_base.base.BaseMVPActivity;
import com.example.tome.module_mvp_home.contract.LoginContract;
import com.example.tome.module_mvp_home.presenter.LoginPresenter;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;

@Route(path = RouterURLS.BASE_MAIN)
public class MainActivity extends BaseMVPActivity<LoginPresenter> implements  LoginContract.View,View.OnClickListener {

    @BindView(R2.id.tv_test)
    Button mTvTest;
    @BindView(R2.id.tv_login)
    Button mTvLogin;
    @BindView(R2.id.tv_data)
    TextView mTvData;

    @Inject
    DataManager mDataManager;

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    //初始化布局
    @Override
    protected int getLayoutId() {
        return R.layout.mvp_home_activity_main;
    }

    //初始化事件和数据
    @Override
    protected void initEventAndData() {
        mTvTest.setOnClickListener(this);
        mTvLogin.setOnClickListener(this);
    }

    //显示数据
    @Override
    public void showLoginData(LoginResponse loginResponse) {
        mTvData.setText(loginResponse.toString());
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.tv_test){
            RouterCenter.toShopCart();
        }else if (v.getId() == R.id.tv_login){
            //网络请求

        }
    }


}
